#include "aeampinfotab.h"
#include <QHeaderView>
#include <QHBoxLayout>
#include <QString>
#include "aeampfeature.h"

AEAmpInfoTab::AEAmpInfoTab(QWidget *parent)
    : MapInfoTab{parent}
    , m_aeAmpFeature{std::make_shared<AEAmpFeature>()}
    , m_pChartBox{new QGroupBox("图谱数据")}
    , m_pChartData{new QTextEdit}
    , m_pMainLayout{new QHBoxLayout(this)}
    , m_pLayout{new QHBoxLayout(this)}
{
    // 创建布局
    m_pLayout->addWidget(m_pChartData);
    m_pChartBox->setLayout(m_pLayout);

    m_pMainLayout->addWidget(m_aeAmpFeature->initUI(this));
    m_pMainLayout->addWidget(m_pChartBox);

    setLayout(m_pMainLayout);

    // 添加AE幅值特性组件
    addFeature(std::dynamic_pointer_cast<IMapInfoFeature>(m_aeAmpFeature));
}

AEAmpInfoTab::~AEAmpInfoTab()
{
    delete m_pChartBox;
    delete m_pChartData;
    delete m_pMainLayout;
    delete m_pLayout;
}

void AEAmpInfoTab::setDataTypeCode(uint8_t code)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setDataTypeCode(code);
    }
}

void AEAmpInfoTab::setDataLength(int32_t length)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setDataLength(length);
    }
}

void AEAmpInfoTab::setCreateTime(const QString& time)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setCreateTime(time);
    }
}

void AEAmpInfoTab::setChartProperty(const DataSpecificationGW::SpectrumCharacter& property)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setChartProperty(property);
    }
}

void AEAmpInfoTab::setDeviceName(const QString& name)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setDeviceName(name);
    }
}

void AEAmpInfoTab::setDeviceCode(const QString& code)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setDeviceCode(code);
    }
}

void AEAmpInfoTab::setMeasurementName(const QString& name)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setMeasurementName(name);
    }
}

void AEAmpInfoTab::setMeasurementCode(const QString& code)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setMeasurementCode(code);
    }
}

void AEAmpInfoTab::setChannelFlag(int64_t flag)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setChannelFlag(flag);
    }
}

void AEAmpInfoTab::setDataType(uint8_t type)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setDataType(type);
    }
}

void AEAmpInfoTab::setAmplitudeUnit(uint8_t unit)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setAmplitudeUnit(unit);
    }
}

void AEAmpInfoTab::setAmplitudeLowerLimit(float lowerLimit)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setAmplitudeLowerLimit(lowerLimit);
    }
}

void AEAmpInfoTab::setAmplitudeUpperLimit(float upperLimit)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setAmplitudeUpperLimit(upperLimit);
    }
}

void AEAmpInfoTab::setUltrasonicSensorType(float type)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setUltrasonicSensorType(type);
    }
}

void AEAmpInfoTab::setDataPointCount(int32_t count)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setDataPointCount(count);
    }
}

void AEAmpInfoTab::setTestFrequency(float frequency)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setTestFrequency(frequency);
    }
}

void AEAmpInfoTab::setDischargeTypeProbability(const QString& probability)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setDischargeTypeProbability(probability);
    }
}

void AEAmpInfoTab::setSignalMaxValue(float value)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setSignalMaxValue(value);
    }
}

void AEAmpInfoTab::setSignalRMSValue(float value)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setSignalRMSValue(value);
    }
}

void AEAmpInfoTab::setCorrelation50Hz(float correlation)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setCorrelation50Hz(correlation);
    }
}

void AEAmpInfoTab::setCorrelation100Hz(float correlation)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setCorrelation100Hz(correlation);
    }
}

void AEAmpInfoTab::setFrequencyBand(uint8_t band)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setFrequencyBand(band);
    }
}

void AEAmpInfoTab::setLowerFrequency(float lowerFreq)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setLowerFrequency(lowerFreq);
    }
}

void AEAmpInfoTab::setUpperFrequency(float upperFreq)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setUpperFrequency(upperFreq);
    }
}

void AEAmpInfoTab::setBackgroundFileName(const QString& fileName)
{
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setBackgroundFileName(fileName);
    }
}

void AEAmpInfoTab::setReservedData(const QByteArray& byte)
{
    // 数据会通过特性组件显示
    if (m_aeAmpFeature) {
        m_aeAmpFeature->setReservedData(byte);
    }
}
